home *** CD-ROM | disk | FTP | other *** search
- #include "proc.h"
-
- /* checks for jetsync application processes still running in which case
- synchronization cannot proceed. */
- int check_processes()
- {
- DIR *d;
- FILE *fp;
- struct dirent *dirp = (struct dirent *) malloc(sizeof(struct dirent));
- char fname[512], str[256];
-
- d = opendir("/proc/");
- while ((dirp = readdir(d))) {
- memset((char *)fname, 0, 512);
- sprintf(fname, "/proc/%s/cmdline", dirp->d_name);
- fp = fopen(fname, "r");
- if (!fp)
- continue;
-
- memset((char *)str, 0, 256);
- fgets(str, 256, fp);
- if (!feof(fp)) continue;
- fclose(fp);
-
- if (strstr(str, "/jetaddr.exe") ||
- strstr(str, "/jetmemo.exe") ||
- strstr(str, "/jettodo.exe") ||
- strstr(str, "ical ")) {
- closedir(d);
- return -1;
- }
- }
- closedir(d);
- return 0;
- }
-